package com.vanzo.some;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import java.util.List;

/**
 * Created by tisen on 2017/8/15.
 */

public class BootBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "BootBroadcastReceiver";
    private static final long duration = 60 * 1000;
    private static final long delay = 10 * 1000;
    public static final String ACTION_TEST = "com.titan.Test";
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "onReceive = reboot");
        Toast.makeText(context, "reboot", Toast.LENGTH_SHORT).show();
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        Intent i = new Intent();
        i.setAction(ACTION_TEST);
//        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, i, 0);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delay, duration, pendingIntent);
    }
}
